package com.wgts.wgts.mvp.view.activity.newpeople;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.wgts.wgts.R;
import com.wgts.wgts.base.BaseActivity;
import com.wgts.wgts.control.recycleview.CustomLineaLayoutManager;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 新人专享
 */
public class NewPeopleActionActivity extends BaseActivity {
    @BindView(R.id.recycle_view)
    RecyclerView recycleView;
    @BindView(R.id.img_back_init)
    ImageView imgBackInit;
    @BindView(R.id.linear_suspension)
    LinearLayout linearSuspension;
    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.relative_suspension)
    RelativeLayout relativeSuspension;

    CustomLineaLayoutManager customLineaLayoutManager;
    @BindView(R.id.tv_suspension_title)
    TextView tvSuspensionTitle;


    private NewPeopleAdapter adapter;

    private ArrayList<String> srcData;

    @Override
    public void init() {
        srcData = new ArrayList<>();
        for (int i = 0; i < 25; i++) {
            srcData.add("");
        }
    }

    @Override
    public void onCreate(Bundle saveInstanceBundle) {
        super.onCreate(saveInstanceBundle);
        setContentView(R.layout.new_people_action_activity);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        tvSuspensionTitle.setText("新人专享");
        customLineaLayoutManager = new CustomLineaLayoutManager(this);
        recycleView.setLayoutManager(customLineaLayoutManager);
        adapter = new NewPeopleAdapter(this, srcData);
        recycleView.setAdapter(adapter);

        recycleView.addOnScrollListener(new RecyclerView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                int firstVisibleItem = customLineaLayoutManager.findFirstVisibleItemPosition();
                if (firstVisibleItem == 0) {
                    relativeSuspension.setVisibility(View.GONE);
                } else {
                    relativeSuspension.setVisibility(View.VISIBLE);
                }
            }
        });
    }
}
